<div id="language-select">
<?php
    if(sizeof($languages) > 0) {
        // Render options as links
        //$lastElement = end($languages);
        foreach($languages as $key => $lang) {
            echo "<div class=\"$key\">";
                if($key != $currentLang) {
                    echo CHtml::link(
                            '',
                            //"/index.php/".Yii::app()->controller->getId()
                            Yii::app()->request->baseUrl.
                                "/index.php/".
                                $key.
                                "/".
                                Yii::app()->controller->getId().
                                '/'.
                                Yii::app()->controller->getAction()->getId(),
                            array('title'=>$lang)
                            //$this->getOwner()->createMultilanguageReturnUrl($key)."/products/"
                        );
                } else echo '<span title=\''.$lang.'\'></span>';
            echo "</div>";
            //if($lang != $lastElement) echo ' | ';
        }
    }
    else {
        // Render options as dropDownList
        echo CHtml::form();
        foreach($languages as $key=>$lang) {
            echo CHtml::hiddenField(
                $key, 
                $this->getOwner()->createMultilanguageReturnUrl($key));
        }
        echo CHtml::dropDownList('language', $currentLang, $languages,
            array(
                'submit'=>'',
            )
        ); 
        echo CHtml::endForm();
    }
    
    echo CHtml::form();
    
?>
</div>
